'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up (queryInterface, Sequelize) {
    /**
     * Add altering commands here.
     */
    await queryInterface.createTable('users', {
      id: {
        type: Sequelize.INTEGER,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false
      },
      name: {
        type: Sequelize.STRING(30),
        allowNull: false
      },
      password: {
        type: Sequelize.STRING(30),
        allowNull: false
      },
      phone: {
        type: Sequelize.STRING(11),
        allowNull: true
      },
      email: {
        type: Sequelize.STRING(30),
        allowNull: true
      },
      status: {
        type: Sequelize.INTEGER,
        defaultValue: 1,
        comment: '0-禁用，1-启用'
      },
      role: {
        type: Sequelize.INTEGER,
        defaultValue: 0,
        comment: '0-普通用户，1-管理员'
      },
      created_at: {
        type: Sequelize.DATE,
        allowNull: false
      },
      updated_at: {
        type: Sequelize.DATE,
        allowNull: false
      }
    });
  },

  async down (queryInterface, Sequelize) {
    /**
     * Add reverting commands here.
     */
    await queryInterface.dropTable('users');
  }
};
